
class MyComposite < MyCompositeLeaf
  attr_accessor :children

  def initialize
    remove_children
  end

  def << composite
    #composite.parent_composite = self
    @children << composite
  end

  def remove composite
    @children -= [composite]
  end
  
  def remove_children
    @children = []
  end

  def children= children
    remove_children
    children.each { |ch| self << ch}
  end

  def visit &block
    if super(&block) != :skip_children
      children.each { |child|
        child.visit(&block)
      }
    end
  end

  def to_s
    children.map().join
  end
end

